<script type="text/javascript">
    $(function () {
        $.fn.dataGridOptions.formSubFun("#form", '/modules/additional/enjoyGoods/doAppend.html');
        //	输入框要求必须为整数数字
        $('.int_figure_required').bind('keyup blur', function () {
            // 不能输入 类似00、01、0000001的数值
            if ($(this).val().match(/^0+\d+/)) {
                this.value = $(this).val().replace(/^0+(\d+)/, '$1');
            }

        });
    });
</script>
<form id="form" method="post" enctype="multipart/form-data">
    <div class="popForm sForm">
        <div class="formitm">
            <label class="lab">名称：</label>

            <div class="ipt"><input type="text" name="name" style="width:120px;" class="name easyui-validatebox"
                                    data-options="required: true,validType:'maxLength[15]'"></div>
        </div>
        <div class="formitm">
            <label class="lab">描述：</label>

            <div class="ipt"><input type="text" name="content" style="width:400px;"  class="name easyui-validatebox"
                                    data-options="required: true,validType:'maxLength[51]'"></div>
        </div>
        <div class="formitm">
            <label class="lab">专区：</label>

            <div class="ipt">
                <select name="prefecture" id="prefecture">
                    <option value="0" selected="selected">--</option>
                    <#list prefectureMap.keySet() as Key>
                        <option value="${Key}" >
                        ${prefectureMap.get(Key)}
                        </option>
                    </#list>
                </select>
            </div>
        </div>
        <div class="formitm">
            <label class="lab">位置：</label>

            <div class="ipt">
                <select name="position" id="position">
                    <option value="0" selected="selected">--</option>
                </select>
            </div>
        </div>
        <div class="formitm">
            <label class="lab">成本价：</label>

            <div class="ipt"><input type="text" name="costPrice" style="width:60px;"
                                    onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
                                    class="amount easyui-validatebox int_figure_required"
                                    data-options="required: true, validType:['numOnly','accout[1,10000]']"
                                    maxlength="5">元
            </div>
        </div>
        <div class="formitm">
            <label class="lab">销售价：</label>

            <div class="ipt"><input type="text" name="price" style="width:60px;"
                                    onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
                                    class="amount easyui-validatebox int_figure_required"
                                    data-options="required: true, validType:['numOnly','accout[1,10000]']"
                                    maxlength="5">元
            </div>
        </div>
        <!--<div class="formitm">-->
            <!--<label class="lab">总数：</label>-->

            <!--<div class="ipt"><input type="text" name="amount" style="width:60px;"-->
                                    <!--onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"-->
                                    <!--class="quota easyui-validatebox int_figure_required"-->
                                    <!--data-options="required: true, validType:['numOnly','copies[1, 100000]']"-->
                                    <!--maxlength="6">份-->
            <!--</div>-->
        <!--</div>-->
    </div>

    <div class="borrowForm">
        <h1 class="borrowFormTitle">商品介绍图片</h1>

        <div id="uploadGuaranteeBox" class="uploadWrap" data-arr="uploadFile">
            <ul id="borrowPagePic" class="photoUpload">
                <li class="addFileBtn">
                    <input type="file" name="file" class="uploadFileInput" id="uploadFile"
                           onchange="return ajaxFileUpload1('uploadFile','/imageUp.jsp?editorid=borrow','picPath');"
                           title="点击上传图片"/>
                </li>
            </ul>
        </div>
    </div>
    <div class="borrowForm">
        <h1 class="borrowFormTitle">商品图片</h1>

        <div id="uploadThumbnailBox" class="uploadWrap" data-arr="uploadThumbnailFile">
            <ul id="borrowThumbnailPic" class="photoUpload">
                <li class="addFileBtn">
                    <input type="file" name="thumbnailFile" class="uploadFileInput" id="uploadThumbnailFile"
                           onchange="return ajaxFileUpload3('uploadThumbnailFile','/imageUp.jsp?editorid=borrow','thumbnailPicPath');"
                           title="点击上传图片"/>
                </li>
            </ul>
        </div>
    </div>

</form>
<script type="text/javascript">seajs.use("${theme_dir}/js/ajaxfileupload");
seajs.use("${theme_dir}/js/upload");</script>
<script type="text/javascript">seajs.use("/plugins/layer/layer.min");
seajs.use("/plugins/layer/skin/layer.css");</script>

<!-- 图片预览-->
<script type="text/javascript">
    $(".fileshow").fancybox();
    $('.l-btn-text').click(function () {
        if ($("#borrowPagePic li").length <= 1) {
            layer.alert('请上传图片资料', 8);
            return false;
        }

        // 功能 #465 后台发标的时候，缩略图改为不是必输项
        /*
         if($("#borrowThumbnailPic li").length<=1){
            layer.alert('请上传缩略图', 8);
            return false;
         }
         */
    })
    $("#prefecture").change(function(){
        $.ajax({
            type:"get",
            url:"/modules/additional/enjoyGoods/enablePosition.html?prefecture="+$(this).val(),
            dataType:"json",
            async:false,
            success:function(data){
                var posHtml = [];
                for(var i=0,len=data.position.length;i<len;i++){
                    if(i==0){
                        posHtml.push('<option selected="selected" value="'+data.position[i]+'">'+data.position[i]+'</option>');
                    }else{
                        posHtml.push('<option value="'+data.position[i]+'">'+data.position[i]+'</option>');
                    }
                }
                $("#position").html(posHtml.join(""));
            }
        });

    })
</script>

